package com.contractpage.ec;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.contractpage.common.persistence.Page;
import com.contractpage.ec.entity.Dict;
import com.contractpage.ec.service.DictService;
import com.contractpage.util.StringUtils;

@Controller
@RequestMapping(value = "dict")
public class DictController {

	@Autowired
	private DictService dictService;

	@RequestMapping(value = "findAllList")
	@ResponseBody
	public Object findAllList(Dict entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return  dictService.findAllList();
	}
	
	@RequestMapping(value = "findList")
	@ResponseBody
	public Object findList(Dict entity, HttpServletRequest request, HttpServletResponse response, Model model){
		Page<Dict> page = new Page<Dict>(request,response);
		return  dictService.findList(page, entity);
	}
	@RequestMapping(value = "save")
	@ResponseBody
	public Object save(Dict entity, HttpServletRequest request, HttpServletResponse response, Model model){
		int i = StringUtils.isEmpty(entity.getId())?dictService.insert(entity):dictService.update(entity);
		return i;
	}
	@RequestMapping(value = "delete")
	@ResponseBody
	public Object delete(Dict entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return dictService.delete(entity);
	}
}